from langchain_experimental.tools import PythonREPLTool
from langchain_openai import ChatOpenAI

key = 'key'
model = ChatOpenAI(model="gpt-3.5-turbo",
                   openai_api_key=key,
                   openai_api_base="https://api.aigc369.com/v1",
                   temperature=0)

tools = [PythonREPLTool()]

model_with_tools = model.bind_tools(tools)

response = model_with_tools.invoke("计算一下3* 5等于多少").tool_calls

print(response)

param = response[0]['args']['__arg1']

input_str = f"""print({param})"""

print(input_str)

print(PythonREPLTool().run(input_str))
